//ajax请求成功
$.requestSuccess = function(obj){
	if($.type(obj) == 'string'){
		obj = $.parseJSON(obj);
	}
	if(obj.success){
		if(obj.msg){
			$.messager.alert($.language.ajax.title,obj.msg);
		}
	}else if(obj.sessionout){
		$.messager.alert($.language.ajax.title,$.language.ajax.sessOut,'error',function(r){
		    top.location.reload();
		});
	}else{
		$.messager.alert($.language.ajax.error,obj.msg||$.language.ajax.operFail);
	}
	return obj.success;
};
//ajax请求错误
$.requestError = function(options){
	var msg;
	if(options.status == 404){
		msg = $.language.ajax.addNotFind;
	}else if(options.status == 500){
		msg = $.language.ajax.operFail;
	}else if(options.status == -1 || options.statusText == 'timeout'){
		msg = $.language.ajax.timeOut;
	}else if(options.status == 200){
		msg = $.language.ajax.parseError;
	}else{
		msg = $.language.ajax.netLinkError;
	}
	$.messager.alert($.language.ajax.error,msg);
};
//全局ajax设置
$.ajaxSetup({
	dataType:'json',
	type:'post',
	timeout:5000,
	global:false,
	cache:false,
	error:$.requestError
});
